from tkinter import*
from tkinter import filedialog,messagebox
from tkinter.ttk import Scrollbar,Checkbutton,Label,Button
import os
import sys
class Notepad(Tk):
    def __init__(self):
        super().__init__()
        self.set_window()
        self.create_menu_bar()
        self.create_tool_bar()
        self.create_body()

    def set_window(self):
        self.title("待办事项")
        max_width,max_height=self.maxsize()
        aligh_center="800x600+%d+%d"%((max_width-800)/2,(max_height-600)/2)
        self.geometry(aligh_center)
        self.iconbitmap()
    def create_menu_bar(self):
        menu_bar = Menu(self)

        file_menu=Menu(menu_bar,tearoff=0)
        file_menu.add_command(label='新建', accelerator="Ctrl+N",command='')
        file_menu.add_command(label='打开', accelerator="Ctrl+O", command='')
        file_menu.add_command(label='保存', accelerator="Ctrl+S", command='')
        file_menu.add_command(label='另存为', accelerator="Ctrl+B", command='')
        file_menu.add_separator()
        file_menu.add_command(label='退出', accelerator="Ctrl+A", command='')

        menu_bar.add_cascade(label='文件',menu=file_menu)


        editor_menu = Menu(menu_bar, tearoff=0)
        editor_menu.add_command(label='撤销', accelerator="Ctrl+2", command='')
        editor_menu.add_separator()
        editor_menu.add_command(label='剪切', accelerator="Ctrl+4", command='')
        editor_menu.add_command(label='复制', accelerator="Ctrl+5", command='')
        editor_menu.add_command(label='粘贴', accelerator="Ctrl+6", command='')
        editor_menu.add_command(label='查找', accelerator="Ctrl+7", command='')
        editor_menu.add_separator()
        editor_menu.add_command(label='全选', accelerator="Ctrl+8", command='')

        menu_bar.add_cascade(label='编辑', menu=editor_menu)

        view_menu = Menu(menu_bar, tearoff=0)
        self.is_show_line_num=IntVar()
        self.is_show_line_num.set(1)
        view_menu.add_checkbutton(label="显示行号",
                                  onvalue=0,offvalue=1,
                                  variable=self.is_show_line_num,command="")
        self.is_heighline_line=IntVar()
        view_menu.add_checkbutton(label="亮度当前行",variable=self.is_show_line_num,command="")
        view_menu.add_separator()
        themes_menu=Menu(menu_bar,tearoff=0)
        themes_menu.add_cascade(label="主题1",command="")
        themes_menu.add_cascade(label="主题2",command="")
        view_menu.add_cascade(label="主题",menu=themes_menu)
        menu_bar.add_cascade(label='视图', menu=view_menu)
        about_menu = Menu(menu_bar, tearoff=0)
        about_menu.add_command(label="关于",command="")
        about_menu.add_command(label="帮助",command="")
        menu_bar.add_cascade(label='关于', menu=about_menu)


        self['menu']=menu_bar
    def create_tool_bar(self):
        tool_bar=Frame(self,height=25,background="#FFFFFF")
        tool_bar.pack(fill="x")
    def create_body(self):
        self.line_number_bar=Text(self,width=4,padx=3,takefocus=0,border=0,background="#f0E68C",state="disable"
                                   )
        self.line_number_bar.pack(side='left',fill='y')
        self.context_text=Text(self,wrap="word",undo=True)
        self.context_text.pack(fill='both',expand="yes")
        self.context_text.tag_config("active_line",background="#EEEEE0")
        scroll_bar=Scrollbar(self.context_text)
        scroll_bar['command']=self.context_text.yview
        self.context_text["yscrollcommand"]=scroll_bar.set
        scroll_bar.pack(side="right",fill="y")
    def open_file(self):
        input_file=filedialog.askopenfilename(filetypes=[("所有文件","*.*"),("文件文档","*.txt")])
if __name__=='__main__':
    app=Notepad()
    app.mainloop()